package cn.csc.module.system.api.social;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
import cn.csc.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
import cn.csc.module.system.api.social.dto.SocialWxaCodeUnlimitReqDTO;
import cn.csc.module.system.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = ApiConstants.NAME) // TODO fallbackFactory =
@Api(tags = "RPC 服务 - 社交应用")
public interface SocialClientApi {

    String PREFIX = ApiConstants.PREFIX + "/social-client";

    @GetMapping(PREFIX + "/get-authorize-url")
    @ApiOperation("获得社交平台的授权 URL")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "socialType", value = "社交平台的类型", example = "1", required = true),
            @ApiImplicitParam(name = "userType", value = "用户类型", example = "1", required = true),
            @ApiImplicitParam(name = "redirectUri", value = "重定向 URL", example = "https://www.iocoder.cn", required = true)
    })
    CommonResult<String> getAuthorizeUrl(@RequestParam("socialType") Integer socialType,
                                         @RequestParam("userType") Integer userType,
                                         @RequestParam("redirectUri") String redirectUri);

    @GetMapping(PREFIX + "/create-wx-mp-jsapi-signature")
    @ApiOperation("创建微信公众号 JS SDK 初始化所需的签名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userType", value = "用户类型", example = "1", required = true),
            @ApiImplicitParam(name = "url", value = "访问 URL", example = "https://www.iocoder.cn", required = true)
    })
    CommonResult<SocialWxJsapiSignatureRespDTO> createWxMpJsapiSignature(@RequestParam("userType") Integer userType,
                                                                         @RequestParam("url") String url);

    @GetMapping(PREFIX + "/create-wx-ma-phone-number-info")
    @ApiOperation("获得微信小程序的手机信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userType", value = "用户类型", example = "1", required = true),
            @ApiImplicitParam(name = "phoneCode", value = "手机授权码", example = "yudao11", required = true)
    })
    CommonResult<SocialWxPhoneNumberInfoRespDTO> getWxMaPhoneNumberInfo(@RequestParam("userType") Integer userType,
                                                                        @RequestParam("phoneCode") String phoneCode);


    @PostMapping(PREFIX + "create-wx-ma-code-unlimit-bytes")
    @ApiOperation("获得微信永久微信二维码")
    @ApiImplicitParam(name = "reqDTO", value = "微信二维码生成参数", dataTypeClass = SocialWxaCodeUnlimitReqDTO.class)
    CommonResult<byte[]> getWxaCodeUnlimitBytes(@RequestBody SocialWxaCodeUnlimitReqDTO reqDTO);


}
